package com.qf.course.web.application;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;

/**
 * description:
 * author: Ken
 * 公众号：Java架构栈
 */
@Configuration
@EnableWebMvc
@ComponentScan("com.qf.course.web")
public class CourseWebConfiguration {

    //上传解析器 - 强制要求上传解析器的Bean的名字必须为 multipartResolver
    @Bean("multipartResolver")
    public CommonsMultipartResolver getCommonsMultipartResolver(){
        System.out.println("上传解析器！");
        CommonsMultipartResolver commonsMultipartResolver = new CommonsMultipartResolver();
        //最大允许上传的文件大小
        commonsMultipartResolver.setMaxUploadSize(1024 * 1024 * 500);
        return commonsMultipartResolver;
    }
}
